$(function (){
    alert("ddd")
    $.getJSON("CartListServlet",function (data){
        console.log(data.goodsMap);
        var cartList=``;
        // 使用Map构造函数将对象转换为Map
        let map = new Map(Object.entries(data.goodsMap));

        // 打印Map
      //  console.log(map);
        //class="car_tr"
        var totalPrice =0;
        for (let [goodId, good] of map) {
            totalPrice += good.price * good.count;
            cartList +=`<tr >
            <td>
            \t<div class="c_s_img"><img src="images/files/${good.fileName}" width="73" height="73" /></div>
               ${good.goodsName}
            </td>
            <td align="center"></td>
            <td align="center">
            \t<div class="c_num">
                    <input type="button" value="" onclick="jianUpdate1(jq(this));" class="car_btn_1" />
                \t<input type="text" value="${good.count}" name="" class="car_ipt" />  
                    <input type="button" value="" onclick="addUpdate1(jq(this));" class="car_btn_2" />
                </div>
            </td>
            <td align="center" style="color:#ff4e00;">￥${good.price * good.count}</td>
            <td align="center"></td>
            <td align="center"><a href="#">删除</a>&nbsp; &nbsp;<a href="#">加入收藏</a></td>
          </tr>`;
        }

        cartList+=` <tr height="70">
          \t<td colspan="6" style="font-family:'Microsoft YaHei'; border-bottom:0;">
            \t<label class="r_rad"><input type="checkbox" name="clear" checked="checked" /></label><label class="r_txt">清空购物车</label>
                <span class="fr">商品总价：<b style="font-size:22px; color:#ff4e00;">￥${totalPrice}</b></span>
            </td>
          </tr>
          <tr valign="top" height="150">
          \t<td colspan="6" align="right">
            \t<a href="#"><img src="images/buy1.gif" /></a>&nbsp; &nbsp; 
              <a href="OrderServlet?totalPrice=${totalPrice}"><img src="images/buy2.gif" /></a>
            </td>
          </tr>`

        $(".car_tab").append(cartList);
    });
})